<?php

class Article_model extends CI_Model {

    public function readArticle($page) {
        $this->db->where("page", $page);
        $requete = $this->db->get('article');
        return $requete->result();
    }

    public function createarticle($titre,$texte,$page) {
        $options = array (
            'titre' =>$titre,
            'texte' => $texte,
            'page' => $page,
            );
      $this->db->insert('article', $options);  
    
    }

    public function udapteAticle($id) {
       
        // set validation properties
        $this->_set_fields();
         
        // prefill form values
        $person = $this->personModel->get_by_id($id)->row();
        $this->validation->id = $id;
        $this->validation->name = $person->name;
        $_POST['gender'] = strtoupper($person->gender);
        $this->validation->dob = date('d-m-Y',strtotime($person->dob));
         
        // set common properties
        $data['title'] = 'Update person';
        $data['message'] = '';
        $data['action'] = site_url('person/updatePerson');
        $data['link_back'] = anchor('person/index/','Back to list of persons',array('class'=>'back'));
     
        // load view
        $this->load->view('personEdit', $data);
    }
    
}

?>
